<template>
  <div>
    <!-- 浮动导航 -->
    <div class="float-link-container">
      <FloatMallLinkComponent/>
    </div>

    <!-- 页面主体 -->
    <div class="main-container">
      <div class="mod-main mod-comm">
        <div class="mt">
          <a @click="newAddressDialogVisible = true" class="e-btn add-btn btn-5" href="javascript:;">新增收货地址</a>
          <span class="ftx-03">您已创建<span class="ftx-02">9 </span>个收货地址，最多可创建<span
              class="ftx-02">25 </span>个</span>
        </div>
        <div class="mc" v-for="addressItem in addressList">
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>{{ addressItem.receiverName }}&nbsp;&nbsp;{{ addressItem.province }}</span>
              <span v-if="addressItem.isDefault" class="default-add">默认地址</span>
              <el-button v-if="!addressItem.isDefault" style="float: right; padding: 3px" type="text">设为默认
              </el-button>
              <el-button style="float: right; padding: 3px 0" type="text">编辑</el-button>
              <el-button style="float: right; padding: 3px" type="text">删除</el-button>
            </div>
            <div class="text item">
              <span class="label">收货人：</span>
              <span class="fl">
                  {{ addressItem.receiverName }}
                </span>
            </div>
            <div class="text item">
              <span class="label">所在地区：</span>
              <span class="fl">
                 {{ addressItem.area }}
                </span>

            </div>
            <div class="text item">
              <span class="label">地址：</span>
              <span class="fl">
                  {{ addressItem.detail }}
                </span>
              <div class="clr"></div>
            </div>
            <div class="text item">
              <span class="label">手机：</span>
              <span class="fl">
                  {{ addressItem.receiverPhone }}
                </span>
            </div>

          </el-card>
        </div>
        <div class="mt" id="addAddressDiv_bottom">
          <a @click="newAddressDialogVisible = true" class="e-btn add-btn btn-5" href="javascript:;">新增收货地址</a>
          <el-dialog title="添加收货地址" :visible.sync="newAddressDialogVisible" width="500px"
                     :close-on-click-modal="false">
            <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="login-from">
              <el-form-item label="收货人" prop="receiverName">
                <el-input v-model="ruleForm.receiverName" autocomplete="off" width="150px">
                </el-input>
              </el-form-item>
              <el-form-item label="所在地区" prop="area">
                <el-input v-model="ruleForm.area" autocomplete="off" width="150px">
                </el-input>
              </el-form-item>
              <el-form-item label="详细地址" prop="detail">
                <el-input v-model="ruleForm.detail" autocomplete="off" width="150px">
                </el-input>
              </el-form-item>
              <el-form-item label="手机号码" prop="receiverPhone">
                <el-input v-model="ruleForm.receiverPhone" autocomplete="off" width="150px">
                </el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                <el-button @click="resetForm('ruleForm')">重置</el-button>
              </el-form-item>
            </el-form>
          </el-dialog>
          <span class="ftx-03">您已创建<span class="ftx-02">9 </span>个收货地址，最多可创建<span
              class="ftx-02">25 </span>个</span>
        </div>
      </div>
    </div>
  </div>

</template>

<script>
import FloatMallLinkComponent from '@/components/FloatMallLinkComponentView.vue';

export default {
  components: {
    FloatMallLinkComponent
  },
  data() {
    return {
      newAddressDialogVisible: false,
      ruleForm: {
        receiverName: '张三',
        receiverPhone: '11111111',
        area: '海淀',
        detail: '达内教育',
      },
      // 表单规则
      rules: {
        receiverName: [
          {required: true, message: '请输入收货人', trigger: 'blur'},

        ],
        receiverPhone: [
          {required: true, message: '请输入所在地区', trigger: 'blur'},

        ],
        area: [
          {required: true, message: '请输入详细地址', trigger: 'blur'},

        ],
        detail: [
          {required: true, message: '请输入手机号码', trigger: 'blur'},

        ],
      },
      dialogTableVisible: false,
      addressList: [
        {
          /**
           * 收货人
           */
          receiverName: '张三',

          /**
           * 收货电话
           */
          receiverPhone: '11111111',

          /**
           * 省名称
           */
          province: '北京',
          /**
           * 市名称
           */
          city: '北京',
          /**
           * 区名称
           */
          area: '海淀',
          detail: '达内教育',
          isDefault: true
        },
        {
          /**
           * 收货人
           */
          receiverName: '张三',

          /**
           * 收货电话
           */
          receiverPhone: '11111111',

          /**
           * 省名称
           */
          province: '北京',
          /**
           * 市名称
           */
          city: '北京',
          /**
           * 区名称
           */
          area: '海淀',
          detail: '达内教育',
          isDefault: false
        },
        {
          /**
           * 收货人
           */
          receiverName: '张三',

          /**
           * 收货电话
           */
          receiverPhone: '11111111',

          /**
           * 省名称
           */
          province: '北京',
          /**
           * 市名称
           */
          city: '北京',
          /**
           * 区名称
           */
          area: '海淀',
          detail: '达内教育',
          isDefault: false
        },
        {
          /**
           * 收货人
           */
          receiverName: '张三',

          /**
           * 收货电话
           */
          receiverPhone: '11111111',

          /**
           * 省名称
           */
          province: '北京',
          /**
           * 市名称
           */
          city: '北京',
          /**
           * 区名称
           */
          area: '海淀',
          detail: '达内教育',
          isDefault: false
        }

      ]
    }
  },
  methods: {
    loadPageTitle() {
      this.pageTitle = '茶叶商城 - 学茶商城网';
      document.title = this.pageTitle;
    },
    loadDefaultSearchKeywords() {
      let defaultSearchKeywords = '大红袍';
      this.defaultSearchKeywords = defaultSearchKeywords;
    },
    loadSearchSuggestKeywords() {
      let searchSuggestKeywords = ['车载杯', '煮茶壶', '铁观音', '五宝茶', '小青柑', '苦荞茶'];
      this.searchSuggestKeywords = searchSuggestKeywords;
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }

  },
  mounted() {
    this.loadPageTitle();
    this.loadDefaultSearchKeywords();
    this.loadSearchSuggestKeywords();

  },
  created() {

  }
}
</script>

<style>
/*通用的去ul默认格式*/
ul, li {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: #4caf50;;
}

body {
  font-family: "微软雅黑", "黑体";
}

.main-container {
  text-align: left !important;
  width: 1200px;
  margin: 0 auto;
}

.mod-main {
  margin-top: 24px;
  padding: 10px;
  background-color: #fff;
  margin-bottom: 20px;
}

.mod-comm {
  padding: 10px 20px 20px;
}

.mod-comm .mt {
  padding: 10px 0;
}

a.add-btn {
  display: inline-block;
  vertical-align: middle;
  font-weight: 700;
  padding: 0 14px;
  height: 28px;
  line-height: 28px;
  font-size: 14px;
  margin: 0 10px 0 0;
}

.btn-5, .btn-6, .btn-7, .btn-8 {
  background-color: rgb(245, 251, 239);
  background-image: linear-gradient(rgb(245, 251, 239) 0px, rgb(234, 246, 226) 100%);
  border-radius: 2px;
  display: inline-block;
  height: 18px;
  line-height: 18px;
  border: 1px solid rgb(191, 214, 175);
  padding: 2px 14px 3px;
  color: rgb(50, 51, 51);
}

.ftx-03, .ftx03 {
  color: #999;
}

.ftx-02, .ftx02 {
  color: #71b247;
}

.mod-comm .mc {
  line-height: 20px;
}

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.label {
  float: left;
  width: 70px;
  color: rgb(153, 153, 153);
  text-align: right;
}

.fl {

}

.el-button--text {
  border-color: transparent;
  color: rgb(0, 94, 167);
  background: 0 0;
  padding-left: 0;
  padding-right: 0;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both
}

.box-card {
  width: 100%;
  /*margin-bottom: 30px;*/
  border: 2px solid rgb(230, 230, 230);
  margin: 0px 0px 10px;
}

.default-add {
  margin: 0 0 0 10px;
  font-size: 12px;
  background: #ffaa45;
  padding: 2px;
  color: #fff;
  font-weight: 400;
}
</style>
